home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / rss / getopcod.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  934 b   |  44 lines

  1. /*
  2. \funcref{getopcode}{OPCODE\_ getopcode (\params)}
  3.     {
  4.         {FILE} {*f} {binary {\em icmake} file}
  5.     }
  6.     {read opcode, or --1 when reading failed}
  7.     {}
  8.     {getstring()}
  9.     {getopcod.c}
  10.     {
  11.         Function {\em getopcode()} attempts to read an opcode from file {\em
  12.         f}. This file must be opened in read/binary mode (see the constant {\em
  13.         READBINARY} in file {\em icm.h}).
  14.  
  15.         When the reading operation fails, --1 is returned.
  16.     }
  17.  
  18. Example:
  19. {\footnotesize
  20.     \begin{verbatim}
  21.         // file 'infile' is assumed to be opened
  22.         OPCODE_
  23.             op;
  24.  
  25.         if ( (op = getopcode (f)) == -1 )
  26.             error ("invalid binary makefile");
  27.         process (op);
  28.     \end{verbatim}
  29. } % end footnotesize
  30. */
  31.  
  32. #include "icrssdef.h"
  33.  
  34. OPCODE_ getopcode (FILE *f)
  35. {
  36.     char
  37.         op = 0;
  38.  
  39.     if (! fread (&op, sizeof (char), 1, f) )
  40.         op = (char) -1;
  41.  
  42.     return ( (OPCODE_) op );
  43. }
  44.